Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Conversation

@coder11
Copy link
Contributor

@coder11 coder11 commented Sep 5, 2022

React test doesn't work, so it has to be skipped (package.json.skip). It is somehow related to pnpm specific and works well in https://github.com/fluencelabs/examples. Will be fixed in separate PR.

@coder11 coder11 requested review from nahsi and shamsartem September 5, 2022 11:04
ci.js Outdated
Comment on lines 39 to 58
async function getFiles(currentPath, files) {
const entries = await fs.readdir(currentPath, { withFileTypes: true });

for (let file of entries) {
if (file.name === "node_modules") {
continue;
}

if (file.isDirectory()) {
await getFiles(`${currentPath}${file.name}/`, files);
} else if (file.name === "package.json") {
const packageJsonPath = path.join(
__dirname,
currentPath,
file.name
);
files.push(packageJsonPath);
}
}
}
Copy link
Contributor

@shamsartem shamsartem Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With help of something like this, we can avoid await inside the loop. Also, I suggest renaming this function, so it's more clear what it does, remove the need to mutate function argument and avoid using template-literal path construction (use join instead). I would also suggest avoiding using __dirname and use process.cwd() or something else because __dirname not supported by ECMAScript modules, so it's not future-proof

const getPackageJsonsRecursive = async (currentPath) => (await Promise.all(
  (await fs.readdir(currentPath, { withFileTypes: true }))
    .filter(({name}) => name !== "node_modules" && (file.isDirectory() || file.name === "package.json"))
    .map(() => file.isDirectory() 
      ? getPackageJsonsRecursive(path.join(currentPath, file.name))
      : Promise.resolve([
          path.join(
            __dirname,
            currentPath,
            file.name
          )
        ])
    )
)).flat()

@@ -0,0 +1,45 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest not to commit this folder with react test since it's not working

Comment on lines +17 to +20
import { isBrowser } from 'browser-or-node';
import { Buffer as BufferPolyfill } from 'buffer';

export default isBrowser ? BufferPolyfill : Buffer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you completely sure all of this in needed? As I remember, this polyfill should just work if you import it without any additional stuff. Please make sure we are not doing extra work here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was meant to include polyfill only for browser usage of the library. However it seems like it results in always using the polyfill.

I decided to just leave a single import from 'buffer' to make things clearer

Copy link
Contributor

@shamsartem shamsartem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments in ci.js file, I think changes I propose are not very hard but can measurably improve the speed of that job. Also left a question in Buffer.ts
I also suggest removing rect_test since it's not working, if for some reason somebody checks out his commit he will find not working code which is not cool I think

@coder11 coder11 requested a review from shamsartem September 5, 2022 15:14
Copy link
Contributor

@shamsartem shamsartem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@coder11 coder11 merged commit 0bf8eb2 into master Sep 5, 2022
@coder11 coder11 deleted the fix-webpack5 branch September 5, 2022 15:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants